﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    /// <summary>
    /// 发货单与运输单号关系
    /// </summary>
    public partial class TJLRWBB13 
    {
        ITXEXRPT ITXEXRPT;
        public TJLRWBB13()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWBBEW();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            // base.vwMaster_CurrentChanged(sender, e);
             

        }
        public override void QueryCommand(object sender, System.Windows.RoutedEventArgs e)
        {
                        
            ART = txtFART.Text.ToString().Trim();            
            if (DTSTART == "")
            {
                DTSTART = "20000000";
            }
            if(DTEND=="")
            {
                DTEND = "99999999";
            }
            dwData = TBMain.NewRow();
            
            dwData["WBEWART"] = ART;
            dwData["WBEWBUCHDAT"] = DTSTART;
            dwData["WBEWWERTDAT"] = DTEND;
            try
            {
                SResult = TMV.QWBBEW13(dwData);
                MergeData(SResult, true, true);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }
        private void PrintCommand(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ITXEXRPT == null)
                {
                    ITXEXRPT = new ITXEXRPT();
                    ITXEXRPT.Root = "C:\\IntexReport";
                    ITXEXRPT.strCompany = app.company;
                    ITXEXRPT.PrintType = "OpenExcel";
                }
                ITXEXRPT.dsSource = SResult;
                //ITXEXRPT.dsSource.Merge(SetEnv);

                ITXEXRPT.DocType = "JLTRWBB13";

                ITXEXRPT.strExcelFile = @"\JLT\JLTview.xls";
                string filename = ITXEXRPT.WriteExcelReport();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void DatePicker_SelectedDateChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {

        }
        
    }
}